exports.vote_list = function (req, res) {

    var restfulParams = req.routeInfo.restfulParams;
   // var bodyParams = req.routeInfo.bodyParams;
    //最终结果
    var resultData = [];

    var skip  =  restfulParams.skip == undefined  ? 0 : restfulParams.skip;
    var limit =  restfulParams.limit == undefined ? config.publicConfig.LIMIT : restfulParams.limit;


    //任务流创建
    async.waterfall([

        //查询我参与的投票列表
        function (cb) {

            R.SEND_HTTP(
                req,
                {
                    url: CORE_APIConfig.coreAPI.searchVoteActivityUserAndActivityInfo + "/sort_order/vau_create_time-desc/vau_uid/" + restfulParams.u_id + "/skip/" + skip + "/limit/" + limit,
                    method: 'GET'
                },
                function (err, data) {
                    //判断是否有错误信息
                    if (err) {
                        return cb(err, data);
                    }

                    resultData= data.data;

                    cb();
                }
            );
        },

        //查询该用户的排名
        function(cb){
       // //console.log(resultData.res);
            if(resultData.length <= 0){
                return cb();
            }

            //创建添加任务
            var tasks = [];

             //循环节点列表
             resultData.forEach(function (item, i) {


                //创建每一个插入任务
                tasks.push(function (cb) {

                    //console.log(item);

                    R.SEND_HTTP(
                        req,
                        {
                            url: CORE_APIConfig.coreAPI.voteUserIntegralRanking,
                            method: 'POST',
                            data : {
                                vau_uid  : item.vau_uid,
                                vau_oaid : item.vau_oaid
                            }
                        },
                        function (err, data) {

                            //console.log(data)
                            
                            item.ranking = data.data[0].rownum;
                         
                            cb();
                        }
                    );


                });

            });
            async.waterfall(tasks, cb);

        },
        function(cb){
            // //console.log(resultData.res);
            if(resultData.length <= 0){
                return cb();
            }

            //创建添加任务
            var tasks = [];

            //循环节点列表
            resultData.forEach(function (item, i) {


                //创建每一个插入任务
                tasks.push(function (cb) {

                    //console.log(item);

                    R.SEND_HTTP(
                        req,
                        {
                            url    : CORE_APIConfig.coreAPI.search_vote_num ,
                            method : 'POST',
                            data : {
                                uid:item.vau_uid,
                                oaid:item.vau_oaid
                            }
                        },
                        function (err, data) {

                            ////console.log("拼团");
                            if(data.data.length > 0){
                                item.num =  data.data[0].NUM;
                            }


                            cb();
                        }
                    );


                });

            });
            async.waterfall(tasks, cb);

        },










        /*************************/

        /************************/

        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}